package com.jdz.gxq.info.admin.employmentneed.service;

import java.util.List;
import java.util.Map;

import jp.terasoluna.fw.dao.QueryDAO;
import jp.terasoluna.fw.dao.UpdateDAO;

import com.jdz.gxq.info.admin.employmentneed.bo.Employmentneed;

public class EmploymentneedServiceImpl implements EmploymentneedService {

	private QueryDAO queryDAO = null;

	private UpdateDAO updateDAO = null;

	/**
	 * Employmentneed检索分页用，查询记录条数
	 * 
	 * @return
	 */
	public int getEmploymentneedsCount(String needTime) {

		int totalCount = queryDAO.executeForObject(
				"employmentneed.getEmploymentneedsCount", needTime,
				Integer.class);

		return totalCount;
	}

	/**
	 * Employmentneed检索
	 * 
	 * @return
	 */
	public List<Employmentneed> getEmploymentneeds(Map<String, Object> params) {

		return queryDAO.executeForObjectList(
				"employmentneed.getEmploymentneeds", params);
	}

	/**
	 * 追加Employmentneed
	 * 
	 * @param employmentneed
	 */
	public void insertEmploymentneed(Employmentneed employmentneed) {

		updateDAO
				.execute("employmentneed.insertEmploymentneed", employmentneed);
	}

	/**
	 * 更新Employmentneed
	 * 
	 * @param employmentneed
	 */
	public void updateEmploymentneed(Employmentneed employmentneed) {

		updateDAO
				.execute("employmentneed.updateEmploymentneed", employmentneed);
	}

	/**
	 * 通过id得到employmentneed
	 * 
	 * @param id
	 * @return
	 */
	public Employmentneed getEmploymentneedById(int id) {

		Employmentneed employmentneed = queryDAO.executeForObject(
				"employmentneed.getEmploymentneedById", id,
				Employmentneed.class);

		return employmentneed;
	}

	/**
	 * 删除Employmentneed
	 * 
	 * @param employmentneed
	 */
	public void deleteEmploymentneed(int id) {

		updateDAO.execute("employmentneed.deleteEmploymentneedById", id);
	}

	// /**
	// * 验证employmentneedName是否重复
	// * flag: 1 追加时验证
	// * flag: 2 更新时验证
	// */
	// public boolean checkEmploymentneedName(Employmentneed
	// paramEmploymentneed, int flag) {
	//
	// Employmentneed employmentneed =
	// queryDAO.executeForObject("employmentneed.getEmploymentneedByName",
	// paramEmploymentneed.getNeedTime(), Employmentneed.class);
	//
	// if (employmentneed == null) {
	// return true;
	// }
	//
	// // 更新验证，查出来的数据是不是本身
	// if (flag == 2) {
	//
	// if (employmentneed.getId() == paramEmploymentneed.getId()) {
	// return true;
	// }
	// }
	//
	// return false;
	// }

	public void setQueryDAO(QueryDAO queryDAO) {
		this.queryDAO = queryDAO;
	}

	public void setUpdateDAO(UpdateDAO updateDAO) {
		this.updateDAO = updateDAO;
	}

}
